package com.miuu.springcloud.controller;

import com.miuu.springcloud.result.JsonResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
public class ConsumerController {
    @Resource
    RestTemplate restTemplate;
    public static String url = "http://localhost:8100/";

    /**
     * 查询
     * @param id
     * @return
     */
    @GetMapping("product/consumer/get/{id}")
    public JsonResult selectById(@PathVariable("id") Long id){

        return JsonResult.ok(200, "查询成功",
                restTemplate.getForObject(url+"product/provider/get/"+id, JsonResult.class));
    }
}
